﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Gufa.Entity.Configs
{
    public class TechConfig : IEntityTypeConfiguration<Tech>
    {
        public void Configure(EntityTypeBuilder<Tech> builder)
        {
            builder.ToTable("T_Teches");
            builder.ToTable(t => t.HasCheckConstraint("CK_DelFlag_Values", "DelFlag IN (0, 1)"));
            builder.Property(tech => tech.Id).IsRequired();
            builder.Property(tech => tech.GroupId).IsRequired();
            builder.Property(tech => tech.TechName).HasMaxLength(20).IsRequired();
            builder.Property(tech => tech.DelFlag).IsRequired()  // 确保字段不为空
               .HasDefaultValue(0)  // 设置默认值为0
               .HasConversion<int>();  // 确保映射到整数类型
        }
    }
}
